package demo1

import "fmt"

// 收音机具体实现类
type Radio struct {
	On      bool
	Volume  int
	Channel int
}

func (r *Radio) IsEnabled() bool {
	return r.On
}

func (r *Radio) Enable() {
	r.On = true
}

func (r *Radio) Disable() {
	r.On = false
}

func (r *Radio) GetVolume() int {
	return r.Volume
}

func (r *Radio) SetVolume(i int) {
	if i > 100 {
		r.Volume = 100
	} else if i < 0 {
		r.Volume = 0
	} else {
		r.Volume = i
	}
}

func (r *Radio) GetChannel() int {
	return r.Channel
}

func (r *Radio) SetChannel(i int) {
	r.Channel = i
}

func (r *Radio) PrintStatus() {
	fmt.Println("----------------")
	fmt.Println("| I'm radio")
	if r.On {
		fmt.Println("| I'm Enabled")
	} else {
		fmt.Println("| I'm Disabled")
	}
	fmt.Printf("| Current Volume is %d\n", r.Volume)
	fmt.Printf("| Current Channel is %d\n", r.Channel)
}
